import { setBaseUrl } from '@/config'
const envConfig = {
  state: {
    envUrl: uni.getStorageSync('envUrl') ? JSON.parse(uni.getStorageSync('envUrl')) : ''
  },
  mutations: {
    SET_ENV: (state, value) => {
      state.envUrl = value
    }
  },
  actions: {
    changeEnv({
      commit
    }, value) {
      commit('SET_ENV', value)
      uni.setStorageSync('envUrl', JSON.stringify(value))
      setBaseUrl(value.value)
    }
  }
}

export default envConfig